var t,
  a = require("../../@babel/runtime/helpers/defineProperty"),
  i = require("../../res/www.a9a.cn.js"),
  e = getApp(),
  n = 2,
  s = !0;
Page({
  data: {
    nTitle: "消息通知",
    btm_nav: "msg",
    btmnavbg_color: "#B8BCCC",
    btmnavbg_rgbcolor: i.c16_rgb("#B8BCCC"),
    triggered: !0,
    loading_flag: !1,
    loading_ico_flag: !1,
    loading_str: "玩命加载中",
  },
  onLoad: function (t) {
    var a = this,
      n = 0,
      s = 0;
    wx.setNavigationBarTitle({ title: a.data.nTitle }),
      e.get_config("_ZEAI").then(function (t) {
        a.setData({ color: e._ZEAI.color, rgbcolor: i.c16_rgb(e._ZEAI.color) });
      }),
      e.get_navigationBarTopHeight(a),
      (i.ifint(t.tguid) || i.ifint(t.admid)) &&
        ((n = i.ifint(t.tguid) ? t.tguid : 0),
        (s = i.ifint(t.admid) ? t.admid : 0)),
      a.setData({ tguid: n, admid: s }),
      this.init();
  },
  init: function () {
    var n = this;
    wx.showLoading({ title: "玩命加载中...", mask: !0 }),
      (s = !1),
      (t = wx.getStorageSync("COOK_U")),
      e.ajax({
        url: "tg.php",
        data: {
          submitok: "MSG",
          openid: t.openid,
          tguid: n.data.tguid,
          admid: n.data.admid,
        },
        success: function (t) {
          switch (t.flag) {
            case "1":
            case 1:
              var e;
              if (0 == t.LIST.length)
                n.setData({
                  btm_nav_msg_num: t.btm_nav_msg_num,
                  LIST: [],
                  party_nodata: !0,
                  nTitle: t.nTitle,
                  SHARE: t.SHARE,
                  MB: t.MB,
                });
              else
                n.setData(
                  ((e = { btm_nav_msg_num: t.btm_nav_msg_num }),
                  a(e, "LIST[0]", t.LIST),
                  a(e, "nTitle", t.nTitle),
                  a(e, "SHARE", t.SHARE),
                  a(e, "MB", t.MB),
                  e)
                );
              break;
            case "flag0":
            case "flag_1":
            case "flag2":
              wx.reLaunch({ url: "reg?t=" + t.flag });
              break;
            default:
              (t.this = n), (t.url = "no"), i.sorry(t);
          }
          (s = !0), wx.hideLoading();
        },
      });
  },
  detailFn: function (n) {
    var s = this;
    i.empty(s.data.MB) || e.openSetting(s.data.MB);
    var d = n.currentTarget.dataset.id,
      o = n.currentTarget.dataset.idx,
      r = n.currentTarget.dataset.idx2;
    (t = wx.getStorageSync("COOK_U")),
      1 == s.data.LIST[o][r].new
        ? e.ajax({
            url: "tg.php",
            data: { submitok: "MSG_detail", id: d, openid: t.openid },
            success: function (t) {
              if (1 == t.flag) {
                var i,
                  e = parseInt(s.data.btm_nav_msg_num);
                1 == s.data.LIST[o][r].new && --e < 0 && (e = 0),
                  s.setData(
                    ((i = {
                      detail: !0,
                      mask_class: "alpha0_100",
                      detail_addtime: s.data.LIST[o][r].addtime,
                      detail_content: s.data.LIST[o][r].content,
                    }),
                    a(i, "LIST[" + o + "][" + r + "].new", 0),
                    a(i, "btm_nav_msg_num", e),
                    i)
                  );
              } else wx.showToast({ title: t.msg, icon: "none", mask: !0 });
            },
          })
        : s.setData(
            a(
              {
                detail: !0,
                mask_class: "alpha0_100",
                detail_addtime: s.data.LIST[o][r].addtime,
                detail_content: s.data.LIST[o][r].content,
              },
              "LIST[" + o + "][" + r + "].new",
              0
            )
          );
  },
  mask_closeFn: function (t) {
    var i = this,
      e = t.currentTarget.dataset.maskid;
    this.setData({ mask_class: "alpha100_0" }),
      setTimeout(function () {
        i.setData(a({}, e, !1));
      }, 500);
  },
  tFn: function (t) {
    var a = t.currentTarget.dataset.t;
    this.setData({
      triggered: !1,
      loading_flag: !1,
      loading_str: "拼命加载中",
      LIST: [],
      party_nodata: !1,
      t: a,
    }),
      this.init();
  },
  nodatabackFn: function () {
    this.setData({
      triggered: !1,
      loading_flag: !1,
      loading_str: "拼命加载中",
      LIST: [],
      party_nodata: !1,
      t: 0,
    }),
      this.init();
  },
  onPullDownRefresh: function () {
    var t = this;
    wx.vibrateShort({ type: "heavy" }),
      setTimeout(function () {
        t.setData({
          triggered: !1,
          loading_flag: !1,
          loading_str: "拼命加载中",
          LIST: [],
          party_nodata: !1,
          t: 0,
        }),
          t.setloading("end", "拼命加载中"),
          (n = 2),
          t.init();
      }, 500);
  },
  setloading: function (t, a) {
    "start" == t
      ? this.setData({ loading_flag: !0, loading_ico_flag: !0, loading_str: a })
      : this.setData({
          loading_flag: !1,
          loading_ico_flag: !1,
          loading_str: a,
        });
  },
  onReachBottom: function () {
    var i = this.data.LIST,
      d = this;
    if (s) {
      (s = !1), d.setloading("start", "拼命加载中");
      var o = { submitok: "MSG", p: n, openid: t.openid, t: d.data.t };
      e.ajax({
        url: "tg.php",
        data: o,
        success: function (t) {
          if (1 == t.flag) {
            var e = i.length;
            if (t.LIST.length < 1)
              return d.setloading("end", "已全部加载完毕"), void (s = !1);
            d.setData(a({}, "LIST[" + e + "]", t.LIST)), (n += 1), (s = !0);
          } else wx.showToast({ title: t.msg, icon: "none", mask: !0 });
          d.setloading("end", "上拉加载更多");
        },
      });
    }
  },
  binnd_scroll: function (t) {
    t.detail.scrollTop > 100
      ? this.setData({ backtop_flag: !0 })
      : this.setData({ backtop_flag: !1 });
  },
  backtopFn: function (t) {
    var i = "scrolltopNum_" + t.currentTarget.dataset.id;
    this.setData(a({}, i, 0));
  },
  onShareAppMessage: function (t) {
    return {
      imageUrl: this.data.SHARE.imgurl,
      title: this.data.SHARE.title,
      path: "/pages/tg/msg",
    };
  },
  onShareTimeline: function () {
    return {
      imageUrl: this.data.SHARE.imgurl,
      title: this.data.SHARE.title,
      query: "",
      path: "/pages/tg/msg",
    };
  },
});
